<template>
  <div class="ke">
    <div class="center">
      <left></left>
      <div class="right">
        <top></top>
        <div class="hei10"></div>
        <div class="powertop">
          <router-link class="powertopli " to="/finance/ke">可返利订单</router-link>
          <router-link class="powertopli " to="/finance/wait">待返利数据</router-link>
          <router-link class="powertopli powertopact" to="/finance/jilu">返利记录</router-link>
        </div>
        <div v-loading='loading' style="padding: 20px;">
          <div class="kflexc">
            <div style="width: 250px; margin-right: 20px;">
              <el-input v-model="all.order_id" placeholder="请输入订单ID"></el-input>
            </div>
            <div style="width: 250px; margin-right: 20px;">
              <el-input v-model="all.mobile" placeholder="请输入生产号码"></el-input>
            </div>
            <div style="margin-right: 20px;">
              <el-date-picker v-model="times2" type="monthrange" @change="changetime2" range-separator="至" value-format="yyyy-MM" start-placeholder="返利月份开始" end-placeholder="返利月份结束"></el-date-picker>
            </div>
            <div style="margin-right: 20px;">
              <el-date-picker v-model="times" type="daterange" @change="changetime" range-separator="至" value-format="yyyy-MM-dd" start-placeholder="充值成功开始" end-placeholder="充值成功结束"></el-date-picker>
            </div>
            <el-button type="primary" round  style="margin-right: 20px;" @click="search()">搜索</el-button>
          </div>
          <div class="hei10" style="margin: 20px 0;"></div>
          <div>
            <el-button type="primary" round  @click="daochu()">导出明细</el-button>
            <el-button type="text" style="margin-right: 20px;" @click="$router.push('/order_export7?id=39&name=返利记录')">查看导出记录</el-button>
          </div>
          <el-table :data="list" border style="width: 100%; margin: 20px 0;">
            <el-table-column align='center' prop='order_id' label="订单ID"></el-table-column>
            <el-table-column align='center' prop='source_sku' label="商品编码"></el-table-column>
            <el-table-column align='center' prop='product_sku' label="商品名称"></el-table-column>
            <el-table-column align='center' prop='mobile' label="生产号码"></el-table-column>
            <el-table-column align='center' prop='activated_at' label="激活时间"></el-table-column>
            <el-table-column align='center' prop='month' label="返利月份"></el-table-column>
            <el-table-column align='center' prop='operator_at' label="登记时间"></el-table-column>
            <el-table-column align='center' prop='name' label="登记人员"></el-table-column>
            <el-table-column align='center' prop='over_time_name' label="是否补领">
              <!-- <template slot-scope="scope">
                <span v-if="scope.row.over_time==1">是</span>
                <span v-if="scope.row.over_time==0">否</span>
              </template> -->
            </el-table-column>
            <el-table-column align='center' prop='rebate_at' label="充值成功时间"></el-table-column>

            <el-table-column align='center' prop='rebate_amount' label="返利金额"></el-table-column>
          </el-table>
          <el-pagination style="text-align: right;" background layout="total,prev, pager, next" :current-page="all.page" @current-change="fanye" :page-size="all.page_size" :total="total"></el-pagination>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import axios from 'axios'
  import top from '@/components/top.vue'
  import left from '@/components/left.vue'
  import foot from '@/components/foot.vue'
  import moment from "moment";
  import XLSX from 'xlsx';
  import {
      read,utils
    } from 'xlsx'

  export default {
    components: {
      "left": left,
      "top": top,
      "foot": foot
    },
    name: "ke",
    data() {
      return {
        times:[],
        times2:[],
        loading:false,
        list:"",
        all:{
          mobile:"",
          order_id:"",
          month_start:"",
          month_end:"",
          rebate_start:"",
          rebate_end:"",
          page:1,
          page_size:20
        },
        total:0,
        log:false
      }
    },
    created() {
      this.getlist()
    },
    mounted() {

    },
    methods: {
      changetime2:function(){
        if (this.times2 != '' && this.times2 != null) {
          this.all.month_start = this.times2[0]
          this.all.month_end = this.times2[1]
        } else {
          this.all.month_start = ''
          this.all.month_end = ''
        }
      },
      changetime:function(){
        if (this.times != '' && this.times != null) {
          this.all.rebate_start = this.times[0]
          this.all.rebate_end = this.times[1]
        } else {
          this.all.rebate_start = ''
          this.all.rebate_end = ''
        }
      },

      //导出
      daochu: function() {
        axios.get('/api/plan-market/rebate/log/list/export',{params:this.all})
          .then(response => {
            if (response.data.msg.code == 0) {
              this.$router.push('/order_export7?id=39&name=返利记录')
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },
      search: function() {
        this.all.page = 1
        this.getlist()
      },
      //翻页
      fanye: function(page) {
        this.loading = true
        this.all.page = page
        this.getlist()
      },
      //获取列表
      getlist: function() {
        axios.get(`/api/plan-market/rebate/log/list`,{params:this.all})
          .then(response => {
            if (response.data.msg.code == 0) {
              this.list = response.data.data.data
              this.total = response.data.data.total
              this.loading = false
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },

    }
  }
</script>

<style lang="scss" scoped>
  .ke {
    .powertop {
    	display: flex;
    	background:#f9f9f9;
    }
    .powertopli {
    	flex-basis: 180px;
    	line-height: 50px;
    	border-bottom: 3px #F9F9F9 solid;
    	color: #727272;
    	border-right: 1px #F9F9F9 solid;
    	font-size: 16px;
    	text-align: center;
    }
    .router-link-active {
    	background: #FFFFFF;
    	border-bottom: 3px #2974FF solid;
    }
    /deep/ .el-pagination.is-background .btn-prev:disabled{ background: rgba(246, 246, 246, 0.3); border: 1px rgba(167, 167, 167, 0.3) solid;}
    /deep/ .el-pagination.is-background .btn-next:disabled{ background: rgba(246, 246, 246, 0.3); border: 1px rgba(167, 167, 167, 0.3) solid;}
    /deep/ .el-pagination.is-background .btn-next{ background: rgba(246, 246, 246,1); border: 1px rgba(167, 167, 167,1) solid;}
    /deep/ .el-pagination.is-background .btn-prev{ background: rgba(246, 246, 246,1); border: 1px rgba(167, 167, 167,1) solid;}
    /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active{ background-color: #2974FF;}
    /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active:hover {
        color: #fff;
    }
    /deep/ .el-pagination.is-background .el-pager li:not(.disabled):hover {
        color: #2974FF;
    }
    /deep/ .el-pager li{ border-radius: 14px; background: rgba(255, 255, 255, 1); border: 1px rgba(167, 167, 167, 0.3) solid;}
    /deep/ .btn-prev{ border-radius: 14px; padding: 0 10px;}
    /deep/ .btn-next{ border-radius: 14px; padding: 0 10px;}

    /deep/ .el-table th{ background: rgb(246, 246, 246);}
    /deep/ .el-input__inner{ line-height: 36px; height: 36px; font-size: 12px; background: rgb(247, 248, 250);  border: 0;}
    /deep/ .el-date-editor .el-range-input{ background: rgb(247, 248, 250); }
    /deep/ .el-button{ padding: 11px 23px !important;}
    /deep/ .el-button--mini{ padding: 6px 15px !important;}
    /deep/ .el-button--danger {
        color: #FFF;
        background-color: #2974FF;
        border-color: #2974FF;
    }
    .team {
    	background: #F9F9F9;
    }
  }
</style>
